import { View } from '@tarojs/components';
import classNames from 'classnames';
import React from 'react';
import { defaultVisibleEnums } from '../../moduleConstants';
import ProductTags from '../ProductTags';
import styles from './index.module.scss';

const ProductTitle = ({ content, product, className = '' }) => {
  const hasTag = content?.showTag === defaultVisibleEnums.show && !!product?.tagList?.length;

  return (
    <>
      <View className={classNames(styles.ProductTitle, { tag: hasTag, [className]: !!className })}>
        {product?.title}
      </View>

      <ProductTags {...{ tagList: product?.tagList, hasTag, className: `${className}-tags` }} />
    </>
  );
};

export default ProductTitle;
